<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        var name="window";
        var obj={
            name:"obj",
            sayName:function(){
                console.log(this.name)
            }
        }
        /* 
        1.onclick
        2.对象的方法中，谁执行方法，this就指向谁
        */
        obj.sayName();
        /* bind可以改变函数运行的上下文环境，bind函数中的参数传谁，this就指向谁 */
        var show=function(){
            console.log(this.name)
        }.bind(obj);
        show();
    </script>
</body>
</html>